In [1]:
from IPython import parallel
clients = parallel.Client(profile='parallel')

In [2]:
print clients.ids
print "Total %i cores"%(len(clients.ids))


[0, 1, 2, 3, 4, 5, 6, 15, 16]
Total 9 cores

In [3]:
%%px --local
import cPickle as pickle
import glob
import os

In [4]:
%%px --local

import sys
sys.path.append("\\\\DAP-NAS\\work\\CNOP")
import cPickle as pickle
import numpy as np
import pandas as pd
from statsmodels.tsa.arima_process import arma_generate_sample
import matplotlib.pyplot as plt
import numpy as np
from CNOP import CNOP
import winsound
def threshold(x,thresholds=[],values=[-1,0,1]):
    for threshold,val in zip(thresholds,values):
        if x < threshold: 
            return val
    return values[-1]
import time
from itertools import repeat
import os
from datetime import datetime
import numpy as np
import numpy.linalg as linalg

In [5]:
%%px --local
def pickle_folder(path, wait_interactive=True, chunksize=1):
    '''Pickles all objects (except !README.txt) from the folder assynchronically'''
    try:
        print "INFO FROM FILE:", file(path+"!README.txt").read()
    except:
        print "NO README file"

    view = clients.load_balanced_view()
    files = os.listdir(path)
    if len(files) < 2:
        raise RuntimeError, "Less than 2 files"
    ar = view.map_async(lambda x: pickle.load(file(x)), 
                        [path+x for x in os.listdir(path) if x != "!README.txt"], 
                        chunksize=chunksize)
    if wait_interactive:
        ar.wait_interactive()
        return ar.get()
    else:
        return ar

def get_folder_info(path):
    print "INFO FROM FILE:", file(path+"!README.txt").read()
    files = os.listdir(path)
    print "With %i files"%(len(files))

In [44]:
get_folder_info("\\\\DAP-NAS\\work\\CNOP\\dumps\\temp\\20150323_212714\\")


INFO FROM FILE: Doing MC on 8 cores, 10000 replications of "full_overlap" with 250 observations
With 10001 files

In [45]:
res250Full=pickle_folder("\\\\DAP-NAS\\work\\CNOP\\dumps\\temp\\20150323_212714\\")


10000/10000 tasks finished after  140 s
done

In [46]:
len(res250Full)


Out[46]:
10000

In [48]:
pickle.dump(res250Full, file("\\\\DAP-NAS\\work\\CNOP\\dumps\\MC 31.03-results\\3Full\\res250_CHECKED", "w"))

In [54]:
del res250Full

In [49]:
get_folder_info("\\\\DAP-NAS\\work\\CNOP\\dumps\\temp\\20150324_101209\\")


INFO FROM FILE: Doing MC on 8 cores, 10000 replications of "full_overlap" with 500 observations
With 10001 files

In [55]:
res500Full=pickle_folder("\\\\DAP-NAS\\work\\CNOP\\dumps\\temp\\20150324_101209\\")


10000/10000 tasks finished after  133 s
done

In [56]:
len(res500Full)


Out[56]:
10000

In [57]:
pickle.dump(res500Full, file("\\\\DAP-NAS\\work\\CNOP\\dumps\\MC 31.03-results\\3Full\\res500_CHECKED", "w"))

In [59]:
get_folder_info("\\\\DAP-NAS\\work\\CNOP\\dumps\\temp\\20150325_051321\\")


INFO FROM FILE: Doing MC on 8 cores, 10000 replications of "full_overlap" with 1000 observations
With 5140 files

In [60]:
res1000Full0=pickle_folder("\\\\DAP-NAS\\work\\CNOP\\dumps\\temp\\20150325_051321\\")


5139/5139 tasks finished after   81 s
done

In [62]:
len(res1000Full0)


Out[62]:
5139

In [63]:
res1000Full1=pickle_folder("\\\\DAP-NAS\\work\\CNOP\\dumps\\temp\\20150326_120353\\")


4861/4861 tasks finished after  132 s
done

In [64]:
pickle.dump(res1000Full0+res1000Full1, file("\\\\DAP-NAS\\work\\CNOP\\dumps\\MC 31.03-results\\3Full\\res1000_CHECKED", "w"))

In [66]:
get_folder_info("\\\\DAP-NAS\\work\\CNOP\\dumps\\temp\\20150323_212714\\")


INFO FROM FILE: Doing MC on 8 cores, 10000 replications of "full_overlap" with 250 observations
With 10001 files

In [24]:
get_folder_info("\\\\DAP-NAS\\work\\CNOP\\dumps\\temp\\20150328_094006\\")


INFO FROM FILE: Doing MC on 15 cores, 4225 replications of "no_overlap" with 500 observations
With 4224 files

In [25]:
get_folder_info("\\\\DAP-NAS\\work\\CNOP\\dumps\\temp\\20150328_004236\\")


INFO FROM FILE: Doing MC on 17 cores, 10000 replications of "no_overlap" with 500 observations
With 5776 files

In [26]:
res500No0=pickle_folder("\\\\DAP-NAS\\work\\CNOP\\dumps\\temp\\20150328_094006\\")


4223/4223 tasks finished after   71 s
done

In [27]:
res500No1=pickle_folder("\\\\DAP-NAS\\work\\CNOP\\dumps\\temp\\20150328_004236\\")


5775/5775 tasks finished after   99 s
done

In [34]:
res500No0 = [[i, ""] for i in res500No0]
res500No1 = [[i, ""] for i in res500No1]

In [37]:
pickle.dump(res500No0+res500No1, file("\\\\DAP-NAS\\work\\CNOP\\dumps\\MC 31.03-results\\1No+\\res500_CHECKED", "w"))

In [70]:
del res100Full

Обработка и проверка дампов


In [81]:
res1000_NOT_CHECKED=pickle.load(file("\\\\DAP-NAS\\work\\CNOP\\dumps\\MC 31.03-results\\2Partial\\res1000_NOT_CHECKED"))

In [82]:
len(res1000_NOT_CHECKED)


Out[82]:
10000

MC analysis


In [2]:
import numpy as np
import numpy.linalg as linalg

In [6]:
def process_dump(path, res_real):
    mc_res = pickle.load(file(path))
    xs = np.array([item[0][0].x for item in mc_res if len(item)==2 and linalg.norm(item[0][0].x, ord=np.inf) < 100 ])
    ses = np.array([item[0][0].se for item in mc_res 
                    if len(item)==2 and linalg.norm(item[0][0].x, ord=np.inf) < 100 \
                    and "se" in item[0][0].keys() and not np.isnan(item[0][0].se).any() \
                    #and linalg.norm(item[0][0].se, ord=np.inf) < 100 ])    
                    ])  
    
    xs = pd.Dataframe(xs)
    ses = pd.Dataframe(ses)
    
    rmse =  ((res_real - xs) ** 2).mean()
    bias = (res_real - xs).mean()
    a_ratio = (ses.mean()/xs.std()).mean()
    m_ratio = (ses.median()/xs.std()).mean()
    
    print "FILE: %s"%(path.split("\\")[-1])
    print "BIAS: %2.3f"%(bias)
    print "RMSE: %2.3f"%(rmse)
    print "A-ratio: %s"%(a_ratio)
    print "M-ratio: %s"%(m_ratio)
    print
    print "XS len: %s" % len(xs)
    print "SE len: %s" % len(ses)
    print "XS variance: %s "% xs.std(axis=0)

In [12]:
res1000_NOT_CHECKED = pickle.load(file(u"C:\\Users\\User\\Dropbox\\Лекции\\ВКР\\My Monte-carlo\\MC 31.03-results\\2Partial\\res100_CHECKED"))

In [116]:
path=u"C:\\Users\\User\\Dropbox\\Лекции\\ВКР\\My Monte-carlo\\MC 31.03-results\\2Partial\\res100_CHECKED"
process_dump(path, res_real)


FILE: res100_CHECKED
BIAS: -0.102
RMSE: 6.714
A-ratio: 5.41139855272e+140
M-ratio: 0.321047317994

In [7]:
beta,   alpha   = [0.6, 0.4, 0.8], [0.85, 1.55]
gammam, mum =     [0.4, 0.3, 0.9], [-1.2, 0.07]
gammap, mup =     [0.2, 0.8, 0.3], [1.28, 2.5]
res_real_full = beta+alpha+gammam+mum+gammap+mup
beta,   alpha   = [0.6, 0.4], [0.9, 1.5]
gammam, mum =     [0.3, 0.9], [-0.67, 0.36]
gammap, mup =     [0.2, 0.3], [0.02, 1.28]
res_real_partial = beta+alpha+gammam+mum+gammap+mup
beta,   alpha   = [0.6], [0.95, 1.45]
gammam, mum =     [0.9], [-1.22, 0.03]
gammap, mup =     [0.8], [-0.03, 1.18]
res_real_no = beta+alpha+gammam+mum+gammap+mup

In [8]:
beta,   alpha   = [0.6, 0.4], [0.9, 1.5]
gammam, mum =     [0.3, 0.9], [-0.67, 0.36]
gammap, mup =     [0.2, 0.3], [0.02, 1.28]
res_real_partial = beta+alpha+gammam+mum+gammap+mup

In [9]:
beta,   alpha   = [0.6], [0.95, 1.45]
gammam, mum =     [0.9], [-1.22, 0.03]
gammap, mup =     [0.8], [-0.03, 1.18]
res_real_no = beta+alpha+gammam+mum+gammap+mup

150 obs


In [191]:
path=u"W:\\CNOP\\dumps\\MC 31.03-results\\3Full\\"
process_dump(path + "res150_CHECKED", res_real_full)


FILE: res150_CHECKED
BIAS: -0.280
RMSE: 10.400
A-ratio: 35935.1136818
M-ratio: 0.175399313066

In [198]:
path=u"W:\\CNOP\\dumps\\MC 31.03-results\\3Full\\"
process_dump(path + "res150_CHECKED", res_real_full)


FILE: res150_CHECKED
BIAS: -0.280
RMSE: 10.400
A-ratio: 0.251587434582
M-ratio: 0.175614207518

XS len: 8514
SE len: 1195
XS variance: [ 1.1554774   1.10966607  2.53651001  2.08770918  2.25000791  1.54851286
  1.61313639  3.41722933  3.93851742  4.94660503  1.40904432  2.392834
  2.85243582  5.24450798  5.32106036] 

In [200]:
process_dump("W:\\CNOP\\dumps\\MC 31.03-results\\2Partial\\res150_CHECKED", res_real_partial)


FILE: res150_CHECKED
BIAS: 0.011
RMSE: 0.978
A-ratio: 4.34731895038e+13
M-ratio: 0.521236619654

XS len: 9972
SE len: 5466
XS variance: [ 0.30280266  0.24669125  0.7045185   0.5066124   0.37580024  0.6462535
  0.66332632  1.0424209   0.56516882  0.79194061  2.33731737  0.87763953] 

In [201]:
process_dump("W:\\CNOP\\dumps\\MC 31.03-results\\1No+\\res150_CHECKED", res_real_no)


FILE: res150_CHECKED
BIAS: -0.041
RMSE: 0.304
A-ratio: 13.4976140604
M-ratio: 0.644672743941

XS len: 9999
SE len: 7315
XS variance: [ 0.20827329  0.54688004  0.41749412  0.46636337  0.48699761  0.63612905
  0.52249531  0.88121121  0.44566477] 

In [ ]:

No Overlap Results:


In [17]:
path_no=u"W:\\CNOP\\dumps\\MC 31.03-results\\1No+\\"
process_dump(path_no + "res100_CHECKED", res_real_no)
print
process_dump(path_no + "res250_CHECKED", res_real_no)
print
#process_dump(path_no + "res500_CHECKED", res_real_no)
print
process_dump(path_no + "res1000_OK", res_real_no)


FILE: res100_CHECKED
BIAS: -0.083
RMSE: 1.297
A-ratio: 5.23583135829e+58
M-ratio: 0.504675009963

FILE: res250_CHECKED
BIAS: -0.029
RMSE: 0.090
A-ratio: 1.10624749965
M-ratio: 0.923506266575


FILE: res1000_OK
BIAS: -0.008
RMSE: 0.020
A-ratio: 0.988147836321
M-ratio: 0.974229890311

In [174]:
path_no=u"W:\\CNOP\\dumps\\MC 31.03-results\\1No+\\"
process_dump2(path_no + "res500_WRONG_FORMAL", res_real_no)


FILE: res500_WRONG_FORMAL
BIAS: -0.016
RMSE: 0.042
A-ratio: 0.983974826146
M-ratio: 0.955236960605

In [162]:
mc_res = pickle.load(file(path_no+"res500_WRONG_FORMAL"))
res_real = res_real_no

In [168]:
mc_res[210][0].x


Out[168]:
array([ 0.50534012,  0.46968066,  1.34641935,  1.35828922, -1.11020074,
        0.9499147 ,  0.81643529, -0.25452674,  0.85107151])

In [ ]:
for i in

In [172]:
xs = np.array([item[0].x for item in mc_res if type(item) != IndexError and type(item[0])!=int
               and linalg.norm(item[0].x, ord=np.inf) < 100 \
               and len(item[0].x) == len(res_real)])
ses = np.array([item[0].se for item in mc_res 
                if type(item) != IndexError and type(item[0])!=int \
                and linalg.norm(item[0].x, ord=np.inf) < 100 \
                and "se" in item[0].keys() and not np.isnan(item[0].se).any()\
                and len(item[0].x) == len(res_real)])    

rmse =  ((res_real - xs) ** 2).mean()
bias = (res_real - xs).mean()
a_ratio = (ses.mean(axis=0)/xs.std(axis=0)).mean()
m_ratio = (np.median(ses, axis=0)/xs.std(axis=0)).mean()

print "FILE: %s"%(path.split("\\")[-1])
print "BIAS: %2.3f"%(bias)
print "RMSE: %2.3f"%(rmse)
print "A-ratio: %s"%(a_ratio)
print "M-ratio: %s"%(m_ratio)


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-172-08899174e2a7> in <module>()
     13 m_ratio = (np.median(ses, axis=0)/xs.std(axis=0)).mean()
     14 
---> 15 print "FILE: %s"%(path.split("\\")[-1])
     16 print "BIAS: %2.3f"%(bias)
     17 print "RMSE: %2.3f"%(rmse)

NameError: name 'path' is not defined

In [175]:
len(xs)


Out[175]:
9996

In [ ]:


In [13]:
mc_res = pickle.load(file(path_no+"res500_CHECKED"))
xs = np.array([item[0][0].x for item in mc_res if len(item)==2 and linalg.norm(item[0][0].x, ord=np.inf) < 100 ])


---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-13-b8f78aefb810> in <module>()
      1 mc_res = pickle.load(file(path_no+"res500_CHECKED"))
----> 2 xs = np.array([item[0][0].x for item in mc_res if len(item)==2 and linalg.norm(item[0][0].x, ord=np.inf) < 100 ])

KeyError: 0

In [15]:
xs=[]
for i,item in enumerate(mc_res):
    print i
    if len(item)==2 and linalg.norm(item[0][0].x, ord=np.inf) < 100 : 
        xs.append(item[0][0].x)


0
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-15-b2ed36692c69> in <module>()
      2 for i,item in enumerate(mc_res):
      3     print i
----> 4     if len(item)==2 and linalg.norm(item[0][0].x, ord=np.inf) < 100 :
      5         xs.append(item[0][0].x)

KeyError: 0

In [38]:
process_dump(path_no + "res500_CHECKED", res_real_no)


---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-38-f5d2c5f3bf91> in <module>()
----> 1 process_dump(path_no + "res500_CHECKED", res_real_no)

<ipython-input-7-b7cc45a6ba54> in process_dump(path, res_real)
      1 def process_dump(path, res_real):
      2     mc_res = pickle.load(file(path))
----> 3     xs = np.array([item[0][0].x for item in mc_res if len(item)==2 and linalg.norm(item[0][0].x, ord=np.inf) < 100 ])
      4     ses = np.array([item[0][0].se for item in mc_res 
      5                     if len(item)==2 and linalg.norm(item[0][0].x, ord=np.inf) < 100 \

AttributeError: 'int' object has no attribute 'x'

In [30]:
mc_res = pickle.load(file(path_no+"res100_CHECKED"))

In [56]:
res500No0[1][0][0].x


Out[56]:
array([ 0.62671246,  1.02496687,  1.47209305,  0.89534815, -1.21529914,
        0.00714367,  0.72925652,  0.19039956,  1.15774118])

In [57]:
mc_res[2][0][0].x


Out[57]:
array([ 0.84679601,  1.37658051,  2.2288862 ,  1.12325832, -0.91816145,
        0.37881604,  1.62014918, -0.16429745,  1.72127041])

Partial overlap


In [58]:
path_no=u"W:\\CNOP\\dumps\\MC 31.03-results\\2Partial\\"
process_dump(path_no + "res100_CHECKED", res_real_partial)
print
process_dump(path_no + "res250_CHECKED", res_real_partial)
print
process_dump(path_no + "res500_CHECKED", res_real_partial)
print
process_dump(path_no + "res1000_CHECKED", res_real_partial)


FILE: res100_CHECKED
BIAS: -0.073
RMSE: 6.881
A-ratio: 5.41139855272e+140
M-ratio: 0.321047317994

FILE: res250_CHECKED
BIAS: 0.049
RMSE: 0.535
A-ratio: 2.49132448918
M-ratio: 0.729842391546

FILE: res500_CHECKED
BIAS: 0.008
RMSE: 0.154
A-ratio: 1.39862764424
M-ratio: 0.833354113928

FILE: res1000_CHECKED
BIAS: -0.003
RMSE: 0.037
A-ratio: 1.01862149737
M-ratio: 0.908802775334

Full overlap


In [156]:
path_no=u"W:\\CNOP\\dumps\\MC 31.03-results\\3Full\\"
process_dump2(path_no + "res100_CHECKED", res_real_full)
print
process_dump2(path_no + "res250_CHECKED", res_real_full)
print
process_dump2(path_no + "res500_CHECKED", res_real_full)
print
process_dump2(path_no + "res1000_CHECKED", res_real_full)


FILE: res100_CHECKED
BIAS: -0.334
RMSE: 29.428
A-ratio: 4.06928585651e+52
M-ratio: 0.18334951266

FILE: res250_CHECKED
BIAS: -0.105
RMSE: 2.185
A-ratio: 8.71899096624e+15
M-ratio: 0.449445462746

FILE: res500_CHECKED
BIAS: -0.046
RMSE: 0.934
A-ratio: 6.4193297699
M-ratio: 0.644375604958

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-156-c1b821479a28> in <module>()
      6 process_dump2(path_no + "res500_CHECKED", res_real_full)
      7 print
----> 8 process_dump2(path_no + "res1000_CHECKED", res_real_full)

<ipython-input-153-f0fe0cec8e53> in process_dump2(path, res_real)
      1 def process_dump2(path, res_real):
      2     mc_res = pickle.load(file(path))
----> 3     xs = np.array([item[0].x for item in mc_res if type(item) != IndexError and linalg.norm(item[0].x, ord=np.inf) < 100                                                    and len(item[0].x) == len(res_real)])
      4     ses = np.array([item[0].se for item in mc_res 
      5                     if type(item) != IndexError and linalg.norm(item[0].x, ord=np.inf) < 100 \

AttributeError: 'tuple' object has no attribute 'x'

In [184]:
path_no=u"W:\\CNOP\\dumps\\MC 31.03-results\\3Full\\"

process_dump2(path_no + "res1000_CHECKED", res_real_full)


FILE: res1000_CHECKED
BIAS: -0.026
RMSE: 0.676
A-ratio: 1.92570525581
M-ratio: 0.677401473318

In [179]:
xs = np.array([item[0].x for item in mc_res if type(item) != IndexError and type(item[0])!=int 
               and type(item[0])!=tuple
               and linalg.norm(item[0].x, ord=np.inf) < 100 \
               and len(item[0].x) == len(res_real)])
ses = np.array([item[0].se for item in mc_res 
                if type(item) != IndexError and type(item[0])!=int \
                and type(item[0])!=tuple
                and linalg.norm(item[0].x, ord=np.inf) < 100 \
                and "se" in item[0].keys() and not np.isnan(item[0].se).any()\
                and len(item[0].x) == len(res_real)])    

rmse =  ((res_real - xs) ** 2).mean()
bias = (res_real - xs).mean()
a_ratio = (ses.mean(axis=0)/xs.std(axis=0)).mean()
m_ratio = (np.median(ses, axis=0)/xs.std(axis=0)).mean()

print "FILE: %s"%(path.split("\\")[-1])
print "BIAS: %2.3f"%(bias)
print "RMSE: %2.3f"%(rmse)
print "A-ratio: %s"%(a_ratio)
print "M-ratio: %s"%(m_ratio)


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-179-c0972ff224c4> in <module>()
     15 m_ratio = (np.median(ses, axis=0)/xs.std(axis=0)).mean()
     16 
---> 17 print "FILE: %s"%(path.split("\\")[-1])
     18 print "BIAS: %2.3f"%(bias)
     19 print "RMSE: %2.3f"%(rmse)

NameError: name 'path' is not defined

In [183]:
del mc_res

In [ ]:


In [ ]:


In [8]:
def process_dump2(path, res_real):
    mc_res = pickle.load(file(path))
    xs = np.array([item[0].x for item in mc_res if type(item) != IndexError and type(item[0])!=int 
                   and type(item[0])!=tuple
                   and linalg.norm(item[0].x, ord=np.inf) < 100 \
                   and len(item[0].x) == len(res_real)])
    ses = np.array([item[0].se for item in mc_res 
                    if type(item) != IndexError and type(item[0])!=int \
                    and type(item[0])!=tuple
                    and linalg.norm(item[0].x, ord=np.inf) < 100 \
                    and "se" in item[0].keys() and not np.isnan(item[0].se).any()\
                    and len(item[0].x) == len(res_real)])    
    
    rmse =  ((res_real - xs) ** 2).mean()
    bias = (res_real - xs).mean()
    a_ratio = (ses.mean(axis=0)/xs.std(axis=0)).mean()
    m_ratio = (np.median(ses, axis=0)/xs.std(axis=0)).mean()
        
    print "FILE: %s"%(path.split("\\")[-1])
    print "BIAS: %2.3f"%(bias)
    print "RMSE: %2.3f"%(rmse)
    print "A-ratio: %s"%(a_ratio)
    print "M-ratio: %s"%(m_ratio)

In [98]:
mc_res = pickle.load(file(path_no + "res100_CHECKED"))
xs = np.array([item[0].x for item in mc_res if type(item) != IndexError and linalg.norm(item[0].x, ord=np.inf) < 100 ])
ses = np.array([item[0].se for item in mc_res 
                if type(item) != IndexError and linalg.norm(item[0].x, ord=np.inf) < 100 \
                and "se" in item[0].keys() and not np.isnan(item[0].se).any()])

In [ ]:
xs=[]
for i, item in enumerate(mc_res):
    print i
    if type(item) != IndexError and linalg.norm(item[0].x, ord=np.inf) < 100:
        xs.append(item[0].x)

In [128]:
xs = [item[0].x for item in mc_res if type(item) != IndexError and linalg.norm(item[0].x, ord=np.inf) < 100 and len(item[0].x) = len(res_resl)]

In [ ]:
np.asarray(xs[0:131])

In [147]:
len(xs[130])


Out[147]:
13

In [126]:
arrs = [np.array([1,2,3]), np.array([4,5,6]), np.array([7,8,9])]

In [127]:
arrs


Out[127]:
[array([1, 2, 3]), array([4, 5, 6]), array([7, 8, 9])]

Autocorrelation


In [9]:
def process_dump(obj, res_real, cutpoints = (.2, .8)):
    if type(obj) is str:
        mc_res = pickle.load(file(obj))
    else:
        mc_res = obj
    xs = np.array([item[0].x for item in mc_res if type(item)==tuple and item[0].success
                   ])
    ses = np.array([np.array(item[0].se)[0] for item in mc_res 
                    if type(item)==tuple and item[0].success
                    #and linalg.norm(item[0][0].x, ord=np.inf) < 100 
                    and "se" in item[0].keys() #and not np.isnan(item[0][0].se).any() \
                    #and linalg.norm(item[0][0].se, ord=np.inf) < 100
                    ])
    ses = np.nan_to_num(ses)
    
    
    xs = pd.DataFrame(xs)
    ses = pd.DataFrame(ses)

    
    rmse =  ((res_real - xs) ** 2).mean().mean()
    bias = (res_real - xs).mean().mean()
    #a_ratio = (ses.mean()/xs.std()).mean()
    #m_ratio = (ses.median()/xs.std()).mean()
    a_ratio = (ses[(ses<ses.quantile(cutpoints[1]))&(ses>ses.quantile(cutpoints[0]))].mean()  \
                  / xs[(xs<xs.quantile(cutpoints[1]))&(xs>xs.quantile(cutpoints[0]))].std()).mean()
    m_ratio = (ses[(ses<ses.quantile(cutpoints[1]))&(ses>ses.quantile(cutpoints[0]))].median()  \
                  / xs[(xs<xs.quantile(cutpoints[1]))&(xs>xs.quantile(cutpoints[0]))].std()).mean()

    if type(obj) is str:
        print "FILE: %s"%(obj.split("\\")[-1])
    print "BIAS: %2.3f"%(bias)
    print "RMSE: %2.3f"%(rmse)
    print "A-ratio: %2.3f"%(a_ratio)
    print "M-ratio: %2.3f"%(m_ratio)
    print
    print "XS len: %s" % len(xs)
    print "SE len: %s" % len(ses)
    #print "SE mean: %s "% ses.mean()
    #print "XS variance: %s "% xs.std()
    
    return xs, ses

Full


In [8]:
get_folder_info("\\\\DAP-NAS\\work\\CNOP\\dumps\\temp\\20150412_132614\\")


INFO FROM FILE: Doing MC on 17 cores, 10000 replications of "autocorrelated_errors" with rho = 0.30 observations
With 744 files

In [9]:
get_folder_info("\\\\DAP-NAS\\work\\CNOP\\dumps\\temp\\20150412_141301\\")


INFO FROM FILE: Doing MC on 17 cores, 9300 replications of "autocorrelated_errors" with rho = 0.30 observations
With 307 files

In [12]:
get_folder_info("\\\\DAP-NAS\\work\\CNOP\\dumps\\temp\\20150412_143656\\")


INFO FROM FILE: Doing MC on 17 cores, 9000 replications of "autocorrelated_errors" with rho = 0.30 observations
With 10046 files

In [13]:
res03full = pickle_folder("\\\\DAP-NAS\\work\\CNOP\\dumps\\temp\\20150412_143656\\")


10045/10045 tasks finished after  332 s
done

In [15]:
pickle.dump(res03full, file("\\\\DAP-NAS\\work\\CNOP\\dumps\\MC 16.04 -autocorrelation results\\resFull03", "w"))

In [56]:
xs, ses = process_dump(res03full, res_real_partial, cutpoints=(0.001,0.9))


BIAS: 0.035
RMSE: 0.177
A-ratio: 1.004
M-ratio: 1.001

XS len: 10037
SE len: 10037

In [57]:
del xs, ses, res03full

In [58]:
get_folder_info("\\\\DAP-NAS\\work\\CNOP\\dumps\\temp\\20150413_005610\\")


INFO FROM FILE: Doing MC on 13 cores, 10000 replications of "autocorrelated_errors" with rho = 0.60 observations
With 9999 files

In [14]:
res06full = pickle_folder("\\\\DAP-NAS\\work\\CNOP\\dumps\\temp\\20150413_005610\\", chunksize=30)


 334/334 tasks finished after  292 s
done

In [15]:
pickle.dump(res06full, file("\\\\DAP-NAS\\work\\CNOP\\dumps\\MC 16.04 -autocorrelation results\\resFull06", "w"))

In [12]:
process_dump(res06full, res_real_partial, cutpoints=(0.001,0.9));


BIAS: 0.140
RMSE: 0.311
A-ratio: 0.992
M-ratio: 0.980

XS len: 9989
SE len: 9988

In [16]:
del res06full

In [17]:
res09full = pickle_folder("\\\\DAP-NAS\\work\\CNOP\\dumps\\temp\\20150413_112135\\", chunksize=30)


 334/334 tasks finished after  329 s
done

In [18]:
pickle.dump(res09full, file("\\\\DAP-NAS\\work\\CNOP\\dumps\\MC 16.04 -autocorrelation results\\resFull09", "w"))

In [19]:
process_dump(res09full, res_real_partial, cutpoints=(0.001,0.9));


BIAS: 0.362
RMSE: 1.118
A-ratio: 1.006
M-ratio: 0.899

XS len: 10013
SE len: 9988

In [20]:
del res09full

In [10]:
res09xs = pickle_folder("\\\\DAP-NAS\\work\\CNOP\\dumps\\temp\\20150415_000032\\", chunksize=30)


 334/334 tasks finished after  307 s
done

In [11]:
pickle.dump(res09xs, file("\\\\DAP-NAS\\work\\CNOP\\dumps\\MC 16.04 -autocorrelation results\\resXs09", "w"))

In [12]:
process_dump(res09xs, res_real_partial, cutpoints=(0.001,0.9));


BIAS: 0.197
RMSE: 0.352
A-ratio: 1.069
M-ratio: 1.015

XS len: 9993
SE len: 9993

In [13]:
del res09xs

In [14]:
res06xs = pickle_folder("\\\\DAP-NAS\\work\\CNOP\\dumps\\temp\\20150414_085358\\", chunksize=30)


 334/334 tasks finished after  245 s
done

In [15]:
pickle.dump(res06xs, file("\\\\DAP-NAS\\work\\CNOP\\dumps\\MC 16.04 -autocorrelation results\\resXs06", "w"))

In [16]:
process_dump(res06xs, res_real_partial, cutpoints=(0.001,0.9));


BIAS: 0.078
RMSE: 0.210
A-ratio: 1.010
M-ratio: 1.009

XS len: 9990
SE len: 9990

In [17]:
del res06xs

In [18]:
res03xs = pickle_folder("\\\\DAP-NAS\\work\\CNOP\\dumps\\temp\\20150413_234307\\", chunksize=30)


 284/284 tasks finished after  275 s
done

In [19]:
pickle.dump(res03xs, file("\\\\DAP-NAS\\work\\CNOP\\dumps\\MC 16.04 -autocorrelation results\\resXs03", "w"))

In [20]:
process_dump(res03xs, res_real_partial, cutpoints=(0.001,0.9));


BIAS: 0.024
RMSE: 0.168
A-ratio: 1.007
M-ratio: 1.016

XS len: 8498
SE len: 8498

In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [35]:
type(res03full[45])


Out[35]:
tuple